<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<title>新建拉群</title>
	<link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/fission/css/iconfont.css">
	<style type="text/css">
		body{
			background: #e9e9e9;
		}
		/*公共头部带搜索*/
		.public_container{
			margin: 20px;
			background: #fff;
		}
		.public_title_container{
			height: 54px;
			padding: 0 20px;
			font-size: 14px;
			display: flex;
			align-items: center;
			background: #f9f9f9;
			border-bottom: 1px solid #f0f0f0;
			justify-content: space-between;
		}
		.public_title_container a{
			fill: #999;
		}
		/*公共表单部分*/
		.public_form_container{
			padding: 20px 20px 40px 20px;
		}
		.public_form_content{
			padding: 24px 40px 24px 0;
			background: #fafafa;
			border: 1px solid #e9e9e9;
			margin-bottom: 8px;
		}
		.public_form_List{
			margin-bottom: 10px;
		}
		.public_form_List:last-child{
			margin-bottom: 0px;
		}
		.public_formTitle_container lable{
			font-size: 13px;
			font-weight: bold;
		}
	</style>
</head>
<body>
	<form class="layui-form" id="form1" action="add_graphic.html">
		<div class="public_container">
			<div class="public_content">
				<div class="public_title_container">
					<p>新建图文</p>
					<a href="javascript:history.back(-1)">
						<svg t="1599462684269" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8055" width="20" height="20"><path d="M501.2992 273.408l1.024-156.16L184.65792 379.904l314.29632 266.1376 0.95232-149.2992c313.86624 42.5984 178.29888 231.3216-0.5632 410.2144 619.5712-404.3776 251.01312-590.6432 1.95584-633.5488z" p-id="8056"></path></svg>
					</a>
				</div>
			</div>
			<div class="public_form_container">
				<div class="public_form_content">
					<div class="public_form_List">
						<div class="public_formTitle_container">
							<lable class="layui-form-label">标题：</lable>
						</div>
						<div class="public_formOther_container">
							<div class="layui-input-block">
								<input type="text" name="title" id="title"  value="{$graphic->title}" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
							</div>
						</div>
					</div>
				</div>
				<div class="public_form_content">
					<div class="public_form_List">
						<div class="public_formTitle_container">
							<lable class="layui-form-label">简介：</lable>
						</div>
						<div class="public_formOther_container">
							<div class="layui-input-block">
								<input type="text" name="briefs" id="briefs" value="{$graphic->briefs}"  required  lay-verify="required"placeholder="请输入简介" autocomplete="off" class="layui-input">
							</div>
						</div>
					</div>
				</div>
				<div class="public_form_content">
					<div class="public_form_List">
						<div class="public_formTitle_container">
							<lable class="layui-form-label" {if $graphic->image}style="margin-top: 50px;"{else}style="margin-top: 19px;"{/if} >封面图片：</lable>
						</div>
						<div class="public_formOther_container">
							<div class="layui-input-block" style="margin-left:0px;">
								<br>
								<img {if !$graphic->image}onerror="this.style.display='none'" {/if} id="pic_miniprogram_pic" src="{$graphic->image}"  style="width: 100px; height: 100px;">
								<input type="hidden" name="miniprogram_pic" value="{$graphic->image}" id="miniprogram_pic" />
								<button type="button" class="layui-btn select_img" data-target="miniprogram_pic">
								  <i class="layui-icon">&#xe67c;</i>上传图片
								</button>
							</div>
						</div>
					</div>
				</div>
				<div class="public_form_content">
					<div class="public_form_List">
						<div class="public_formTitle_container">
							<lable class="layui-form-label">详细内容：</lable>
						</div>
						<div class="public_formOther_container">
							<div class="layui-input-block">
							  <textarea id="demo" name="demo" style="display: none;">{$graphic->content}</textarea>
							</div>
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<a class="layui-btn" lay-submit lay-filter="formDemo">立即提交</a>
					</div>
				</div>
			</div>
		</div>
	</form>
<script src="/cdn/jquery.js"></script>
<script src="/layui/layui.all.js"></script>
<script src="/js/ajax.js"></script>
<script type="text/javascript">
	function check(){
		var title = $("#title").val();
		var briefs = $("#briefs").val();
		var miniprogram_pic = $("#miniprogram_pic").val();
		// myAjaxPost(false, true, '', { miniprogram_pic:miniprogram_pic,briefs:briefs,title:title}, function (resp) {
		// 	console.log(resp);
		// })
	}
</script>
<script>
	$('.select_img').on('click',function  () {
	  	var targetId=this.getAttribute('data-target');
	  	layer.open({
			title:'图片库',
			type: 2,
			area: ['700px', '450px'],
			fixed: false, //不固定
			maxmin: false,
			content: '/imgLib/lib.html?type=vshop_img&target='+targetId
	  	});
	})

	window.uploadImgCallback=function (tgt,url) {
	  console.log('选择图片结果',tgt,url);
	  if(tgt=='image'){
		var inputEle=$('#image');
		var prevEle=$('#pic_image');
		inputEle.val(url);
		prevEle.attr('src',url);
		prevEle.show();
	  }else if(tgt=='link_pic'){
		var inputEle=$('#link_pic');
		var prevEle=$('#pic_link_pic');
		inputEle.val(url);
		prevEle.attr('src',url);
		prevEle.show();
	  }else if(tgt=='miniprogram_pic'){
		var inputEle=$('#miniprogram_pic');
		var prevEle=$('#pic_miniprogram_pic');
		inputEle.val(url);
		prevEle.attr('src',url);
		prevEle.show();
	  }
	};
</script>
<script>
layui.use('layedit', function(){
  	var layedit = layui.layedit;
	layedit.set({
	  	uploadImage: {
	    	url: 'add_file.html' //接口url
	    	,type: '' //默认post
	  	}
	});
  	var index = layedit.build('demo',{
  		tool: ['italic','|','strong','|','link','|', 'unlink','|','image','|','left','|','center','|','right','|','underline','|','del']
  	}); //建立编辑器
  	layui.use('form', function(){
		var form = layui.form;
		form.on('submit(formDemo)', function(data){
			var content = layedit.getContent(index);
			var briefs = $("#briefs").val();
			var title = $("#title").val();
			var miniprogram_pic = $("#miniprogram_pic").val();
			if(!content || !miniprogram_pic){
				return false;
			}
			myAjaxPost(false, true, '', { content:content,briefs:briefs,title:title,miniprogram_pic:miniprogram_pic}, function (resp) {
				if (resp.status == 'success') {
					tusi(resp.msg);
					setTimeout(function(){
						location.href = 'index.html'; 
					},2000);
				}else{
					alert(resp.msg);
				}
			});
		});
	})
});
</script>

</body>
</html>